/** 设置类的字段可枚举，用于解决访问器属性无法遍历 */
export function setClassKeysEnumerable<T extends abstract new (...args: any) => any>(
  constructor: T,
  instance: InstanceType<T>,
  keys: string[]
) {
  // 设置字段可枚举，避免克隆丢失
  keys.forEach(key => {
    const desc = Object.getOwnPropertyDescriptor(constructor.prototype, key)

    if (desc) {
      desc.enumerable = true

      Object.defineProperty(instance, key, desc)
    }
  })
}
